package com.iflytek.universitymanagement.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iflytek.universitymanagement.domain.ScoreAnalysisResult;
import com.iflytek.universitymanagement.domain.StudentGrowth;
import com.iflytek.universitymanagement.domain.StudentScore;
import com.iflytek.universitymanagement.domain.StudyHabit;
import com.iflytek.universitymanagement.service.StudentGrowthService;
import com.iflytek.universitymanagement.service.StudentScoreService;
import com.iflytek.universitymanagement.service.StudyHabitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/student-feedback")
public class StudentFeedbackController {

    @Autowired
    private StudyHabitService studyHabitService;

    @Autowired
    private StudentScoreService studentScoreService;

    @Autowired
    private StudentGrowthService studentGrowthService;

    // 分页查询所有学习习惯及学生姓名
    @GetMapping("/study-habits")
    public Page<StudyHabit> getStudyHabits(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "5") int size) {
        Page<StudyHabit> pageRequest = new Page<>(page, size);
        return studyHabitService.getAllHabitsWithStudentName(pageRequest);
    }

    // 分页查询所有学生成长数据及学生姓名
    @GetMapping("/student-growths")
    public Page<StudentGrowth> getAllStudentGrowths(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "5") int size) {
        Page<StudentGrowth> pageRequest = new Page<>(page, size);
        return studentGrowthService.getAllStudentGrowthsWithNames(pageRequest);
    }


    // 分页查询学生成绩分析
    @GetMapping("/analysis/all")
    public Page<ScoreAnalysisResult> getAllStudentScoreAnalysis(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size) {
        Page<StudentScore> pageRequest = new Page<>(page, size);
        return studentScoreService.getAllStudentScoreAnalysis(pageRequest);
    }
}
